package demo01;

public class lx09 {
    public static void main(String[] args) {
        for (int num1 = 1; num1 <= 1000; num1++) {
            if (isPerfectNumber(num1)) {
                System.out.println(num1);
            }
        }
    }

    private static boolean isPerfectNumber(int num) {
        int sum = 0;
        for (int i = 1; i <= num / 2; i++) {
            if (num % i == 0) {
                sum += i;
            }
        }
        return sum == num;
    }
}
